/*
 * @Author: zhangwenbangde@163.com
 * @Date: 2019-04-18 16:45:53
 * */
import Vue from 'vue'
import VueRouter from 'vue-router'
import {
  routerMode
} from '@/env'

import Pay from '@/views/pay/pay.vue'
import Equity from '@/views/equity/equity.vue'
import mainpage from '@/views/mainpage/mainpage.vue'
import order from '@/views/personalCenter/order/order.vue'
import orderRules from '@/views/personalCenter/order/orderRules.vue'
import ticketCode from '@/views/personalCenter/ticketCode/ticketCode.vue'
import personal from '@/views/personalCenter/personal/personal.vue'
import City from '@/views/city/city.vue'
import Point from '@/views/point/point.vue'
import result from '@/views/result/result.vue'
import fail from '@/views/result/fail.vue'


Vue.use(VueRouter);
const routes = new VueRouter({
  mode: routerMode,
  routes: [{
  path: '/',
  name: 'mainpage',
  component: mainpage
}, {
  path: '/equity',
  name: 'equity',
  // meta: {
  //   requireAuth: true // 添加该字段，表示进入这个路由是需要登录的
  // },
  component: Equity
}, {
  path: '/pay',
  name: 'pay',
  component: Pay
}, {
  path: '/mainpage',
  name: 'mainpage',
  component: mainpage
}, {
  path: '/personal',
  name: 'personal',
  component: personal // 个人中心
}, {
  path: '/order',
  name: 'order',
  component: order // 我的订单
}, {
  path: '/orderRules',
  name: 'orderRules',
  component: orderRules // 我的订单
}, {
  path: '/ticketCode',
  name: 'ticketCode',
  component: ticketCode // 用户券码
}, {
  path: '/city',
  name: 'city',
  component: City 
}, {
  path: '/point',
  name: 'point',
  component: Point 
}, {
  path: '/result',
  name: 'result',
  component: result 
}, {
  path: '/fail',
  name: 'fail',
  component: fail 
}]})


// routes.beforeEach((to, from, next) => {

//   if(to.matched.some((item) => item.meta.login)){
//     // 如果是需要登录的，执行....
//     let info = JSON.parse(localStorage.getItem('userWhether'));
//     if(info === 200){  // 已经登录
//         next()
//     }else{
//       routes.push({
//         path: '/noPermission',
//         query: {
//           redirect: to.path.slice(1)
//         }
//       })
//     }

//     let loginStatus = LocalStorage.getLocalStorage('loginStatus');
//     if(loginStatus){
//       Resource.removeLogin
//         .post({}, { matrixContent: loginStatus})
//         .then(res => {
//           if (res.head.resultCode == 'SUCCESS') { // 已发送
//             let token = res.head.token;
//             LocalStorage.setLocalStorage('token', token, 90 * 24 * 60 * 60 * 1000);
//           }
//         })
//         .catch(err => {
//           console.log(err);
//         });
//     }
//   }else{
//     next()
//   }
// });


export default routes

